/** 
系统角色
 **/
package com.cd2cd.code_template.controller;

import com.cd2cd.code_template.configuration.authority.AuthControl;
import com.cd2cd.code_template.configuration.constants.AuthTypeEnum;
import com.cd2cd.code_template.service.SysRoleService;
import com.cd2cd.code_template.vo.BaseRes;
import com.cd2cd.code_template.vo.PageData;
import com.cd2cd.code_template.vo.SysRoleVo;
import javax.annotation.Resource;
import javax.annotation.Title;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("sys-role")
@AuthControl(name = "角色管理",type = AuthTypeEnum.Backend,routePath = "/system-role/page")
public class SysRoleController {

    @Resource
    private SysRoleService sysRoleService;

    /**
     * @gen_896_lwl
     * 角色列表
     * 角色列表
     * @param sysRoleVo
    **/
    @Title("角色列表")
    @ResponseBody
    @RequestMapping(value="list", method=RequestMethod.GET)
    public BaseRes<PageData<SysRoleVo>> getRoleList(SysRoleVo sysRoleVo) {
        return sysRoleService.getRoleList(sysRoleVo);
    }

    /**
     * @gen_897_lwl
     * 添加角色
     * 添加角色
     * @param sysRoleVo
    **/
    @Title("添加角色")
    @ResponseBody
    @RequestMapping(value="info", method=RequestMethod.POST)
    public BaseRes<String> addRole(@RequestBody SysRoleVo sysRoleVo, BindingResult bindingResult) {
        return sysRoleService.addRole(sysRoleVo);
    }

    /**
     * @gen_898_lwl
     * 修改角色
     * 修改角色
     * @param sysRoleVo
    **/
    @Title("修改角色")
    @ResponseBody
    @RequestMapping(value="info", method=RequestMethod.PUT)
    public BaseRes<String> updateRole(@RequestBody SysRoleVo sysRoleVo, BindingResult bindingResult) {
        return sysRoleService.updateRole(sysRoleVo);
    }

    /**
     * @gen_899_lwl
     * 删除角色
     * 删除角色
     * @param sysRoleVo
    **/
    @Title("删除角色")
    @ResponseBody
    @RequestMapping(value="info", method=RequestMethod.DELETE)
    public BaseRes<String> delRole(@RequestBody SysRoleVo sysRoleVo, BindingResult bindingResult) {
        return sysRoleService.delRole(sysRoleVo);
    }

    /**
     * @gen_900_lwl
     * 角色详情
     * 角色详情
     * @param sysRoleVo
    **/
    @Title("角色详情")
    @ResponseBody
    @RequestMapping(value="info", method=RequestMethod.GET)
    public BaseRes<SysRoleVo> roleDetail(SysRoleVo sysRoleVo) {
        return sysRoleService.roleDetail(sysRoleVo);
    }
}